$(function () {
    let facilitiesId = localStorage.getItem("facilitiesId");
    findByFacilitiesId(facilitiesId);
});

function findByFacilitiesId(id) {
    $.ajax({
        url: '/back/facilities/findByFacilitiesId',
        data: {id: id},
        type: 'get',
        dataType: 'json',
        success: function (data) {
            setData(data.facilitiesModel);//需要给数据  把后台数据拿到
        }
    })
}

function setData(data) {
    $("#facilitiesId").val(data.id);
    $("#type").val(data.type);
    $("#title").val(data.title);
    $("#author").val(data.author);
    $("#content").val(data.content);
    $("#releaseTime").val(data.releaseTime);
}

function facilitiesEdit() {
    var data = {};
    data.id = $("#facilitiesId").val();
    data.type = $("#type").val();
    data.title = $("#title").val();
    data.author = $("#author").val();
    data.content = $("#content").val();
    data.releaseTime = $("#releaseTime").val();
    $.ajax({
        url: '/back/facilities/facilitiesEdit',
        data: data,
        type: 'post',
        dataType: 'json',
        success: function (data) {
            if (data.result === 1) {
                alert("修改成功!");
                $("#right").load('/back/facilities/facilitiesManage.html');
            } else {
                alert("修改失败!")
            }
        }
    })
}
function cancelFcEdit() {
    $("#right").load('/back/facilities/facilitiesManage.html')
}